import render from 'src/hrpub/common/frame/render';
import './index.less';

import {createPage,high} from 'nc-lightapp-front';
import Header from '../components/Header';
import DetailPage from '../components/Detail';
import EmptyPage from 'src/hrpub/common/components/emptyImg/index';
import Pagination from 'src/hrpub/common/components/Pagination';
import ApproveDetail from 'uap/common/components/ApproveDetail';
import WpsModal from '../../../../hrpub/common/components/wpsPreModel';
/*const {
    //  ApproveDetail,
    ApprovalTrans } = high;*/
import ApprovalTrans from 'uap/common/components/approvalTrans';
import MainAction from "../actions/main";
import ButtonAction from "../actions/btn";
import TableAction from "../actions/table";
import DetailAction from "../actions/detail";
import {COMMON} from "../main/util";
import BatchAddAction from "../actions/batchAdd";
import BatchAddModal from "../components/BatchAddModal";
import FileManager from "../components/Uploader";
import Excute from "../components/Excute";
import OrganizationModal from "../components/OrganizationModal";
import ViewContractModal from '../components/ViewContract';
import HeadAction from "../components/Header/actions/index.js"
import {THEME} from "../../../public/theme/theme";
import ViewCard from 'src/hrpub/common/components/card-view';
const Homepage = render({
    actions: {
        mainAct: MainAction,
        btnAct: ButtonAction,
        tableAct: TableAction,
        detailAct: DetailAction,
        batAddAct: BatchAddAction,
        headAct: HeadAction
    },
    state:{
        tableHeight:null
    }
})(({props, action, state}, {customData}) => {
    const {transfer, button, editTable, search} = props;
    let {pageInfo} = transfer;
    const pageParam = {
        current: ~~pageInfo.pageIndex,//当前页面, 从 1 开始计算，如果传入了这个props，则组件视为可控组件
        defaultPageSize: pageInfo.pageSize,// 默认每页条数
        hideOnSinglePage: false,// 只有一页时是否隐藏分页器
        pageSize: pageInfo.pageSize,// 每页条数
        pageSizeOptions: [10, 50, 100, 150, 200],// 指定每页显示多少条
        showQuickJumper: false,// 是否可以快速跳转至某页
        showSizeChanger: true,// 是否可以改变pageSize
        showTotal: '',// 函数 用于展示有多少条
        total: pageInfo.total,// 数据总数
        onChange: action.tableAct.paginationEve,// 页码改变回调函数
        onShowSizeChange: action.tableAct.pageSizeSelect// pageSize改变的回调函数
    };
    return (
        <div className={`transfer_management ${THEME.bgCommon}`}>
            <Header
                {...props}
                onBtnOperation={action.btnAct.headerClick}
                back={action.btnAct.back}
            />
            <Choose>
                <When condition={transfer.page === COMMON.pageMain}>
                    <If condition={transfer.hrorgval}>
                        <div className={'table-info'}>
                            {editTable.createEditTable(COMMON.tableId, {
                                showCheck: true,
                                // height: state.tableHeight
                                adaptionHeight:true,
                                otherAreaHeight:transfer.pageInfo.total ? 50:0,
                                // onSelectedAll: action.tableAct.selectAll,
                                // onRowDoubleClick: action.tableAct.doubleClick
                            })}
                        </div>
                        <div className={'pagination-box'}>
                            <Pagination
                                {...pageParam}
                            />
                        </div>
                    </If>
                    <If condition={transfer.language && !transfer.hrorgval}>
                        <EmptyPage
                            text={transfer.language['gx6008-000077']/**暂无数据，请先选择人力组织 */}
                        />
                    </If>
                </When>
                <When condition={transfer.page === COMMON.pageDetail}>
                    <DetailPage
                        {...props}
                    />
                </When>
            </Choose>

            {/*批量新增*/}
            <BatchAddModal
                {...props}
            />

            {/*编制情况*/}
            <OrganizationModal
                {...props}
            />

            {/*合同查看*/}
            <ViewContractModal
                {...props}
            />

            {/*查询*/}
            <div style={{
                display: 'none'
            }}>
                {search.NCCreateSearch(COMMON.searchId, {
                    clickSearchBtn: action.mainAct.toSearch
                })}
            </div>

            <If condition={transfer.fileManagerModalVisible}>
                <FileManager
                    billId={transfer.fileManagerBillId}
                    onClose={action.mainAct.closeModal('fileManagerModalVisible')}
                />
            </If>

            <If condition={transfer.excuteVisible}>
                <Excute
                    {...props}
                    onClose={action.mainAct.closeModal('excuteVisible')}
                    queryDetailData={action.detailAct.queryDetailData}
                />
            </If>
            <If condition={transfer.approveDetail}>
                {/** billid: 单据主键*/}
                {/** billtype： 单据类型*/}
                {/** wokfowtype: 流程类型（审批流/工作流)*/}
                {/** pk_detail: 审批详情主键*/}
                {/** approveType: 是否是审批流类型*/}
                {/** pagecode：节点编码*/}
                {/** btns: 审批弹窗上需要展示的按钮*/}
                {/** pk_checkflow ：审批详情主键*/}
                {/** onHandleSuccess ： 按钮事件成功的回调*/}
                <ApproveDetail
                    show={transfer.approveDetail}
                    close={action.mainAct.closeModal('approveDetail')}
                    billid={transfer.billid}
                    billtype={transfer.billtype}
                />
            </If>
            {transfer.compositedisplay ? <ApprovalTrans
                    title={transfer.language['10140CUSTPF-000034']}/* 国际化处理： 指派*/
                    data={transfer.compositedata}
                    display={transfer.compositedisplay}
                    getResult={action.btnAct.getResult}
                    cancel={action.btnAct.turnOff}
                /> : ""}
                {/* 联查卡片 */}
			 {/* <ViewCard
                    { ...props }
                    onRef ={ 
                        node => transfer.nodeRefs.showCardViewRefs = node
                    }
                ></ViewCard> */}
                 <WpsModal
                    {...props}
                    onRef ={ref => transfer.nodeRefs.wpsview = ref}
                    appcode={COMMON.appConfig.appcode}
                    pk_org={transfer.hrorgobj}
                   
                />
        </div>
    )
});

export default createPage({
    billinfo:[
        {
            billtype: 'grid',
            pagecode: "60092050batch",
            bodycode: 'org'
        },
        {
            billtype: 'grid',
            pagecode: "60092050batch",
            bodycode: 'dept'
        },
        {
            billtype: 'grid',
            pagecode: COMMON.appConfig.pagecode,
            bodycode: 'list'
        },
        {
            billtype: 'grid',
            pagecode: COMMON.appConfig.pagecode,
            bodycode: 'list_batch'
        },
        {
            billtype: 'extcard',
            pagecode: COMMON.appConfig.pagecode,
            headcode: COMMON.formId,
            bodycode: ['psninfo','oldinfo','newinfo','stapply_mng_org','contract_mng_org','execinfo','table_end_info','audit_info']
        },
        {
            billtype: 'extcard',
            pagecode: '60092050batch',
            headcode: COMMON.formId2,
            bodycode: ["psninfo_batch","newinfo_batch","newinfo_org_batch","contract_mng_org_batch","exeinfo_batch","endinfo_batch"]
        }
    ]
})(Homepage)
